<template>
  <div class="" style="height: 600px;">
    <scroll class="wrapper"
          ref="scroll"
          :mouse-wheel="true"
          :pull-up-load="pullUpLoad"
          :scrollbar="true"
          @pullingUp="pullingUp"
          >
      <ul class="list-unstyled px-2">
        <li class="media" v-for="item in topics.rows" :key="item.ctime" @click="lookTopic(item)">
          <!-- <img class="mr-3" style="width: 64px;" :src="item.basicThumbnails" alt="Generic placeholder image"> -->
          <div class="mr-3" style="width: 64px;" v-if="item.basicThumbnails">
            <div class="zoomImage" v-lazy:background-image="item.basicThumbnails"></div>
          </div>
          <div class="media-body">
            <h5 class="mt-0 mb-1 word-break">{{item.basicTitle}}</h5>
            <p class="word-break">{{item.basicDescription}}&nbsp;.&nbsp;.&nbsp;.&nbsp;&nbsp;&nbsp;</p>
          </div>
        </li>
      </ul>
    </scroll>
  </div>
</template>

<script>
import PagedList from '../../plugins/PagedList'

export default {
  name: "topiclist",
  title: "话题列表",
  data () {
    return {
      topics: new PagedList('/mscs/topic/findTopicBasicByType', 10),
      pullUpLoad: {
        txt: {
          more: '加载更多',
          noMore: '没有了'
        }
      }
    }
  },
  mounted () {
    this.search()
  },
  methods: {
    search() {
      this.topics.search()
    },
    pullingUp () {
      if (!this.topics.hasMore) {
        this.$refs.scroll.forceUpdate(this.topics.hasMore)
        return
      }
      this.topics.addLoad().then(() => {
        this.$refs.scroll.forceUpdate(this.topics.hasMore)
      })
    },
    lookTopic (row) {
      this.$router.push({name: 'topicdetails', params: {row: row}})
    },
  }
}
</script>
